<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
	<ul class="nav nav-tabs">
		<li><a href="{:url('AdminOauth/dutyList')}">职称配置列表</a></li>
        <li class="active"><a href="{:url('AdminOauth/dutyForm')}"><if condition="empty($data['id'])">添加<else />编辑</if>职称</a></li>
	</ul>
	<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('AdminOauth/dutyForm')}" onsubmit="submitTest();">
		<div class="form-group">
			<label class="col-sm-2 control-label"><span class="form-required">*</span>职称:</label>
			<div class="col-md-6 col-sm-10">
				<input type="text" class="form-control" name="duty" value="{$data.duty|default=''}">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label"><span class="form-required">*</span>会议权限:</label>
			<div class="col-md-6 col-sm-10">
				<select id="is_meeting" name="is_meeting" class="form-control">
					<option value="0" <?php if($data['is_meeting']==0) echo 'selected="selected"';?>>无</option>
					<option value="1" <?php if($data['is_meeting']==1) echo 'selected="selected"';?>>有</option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label"><span class="form-required">*</span>直播权限:</label>
			<div class="col-md-6 col-sm-10">
				<select id="is_straming" name="is_straming" class="form-control">
					<option value="0" <?php if($data['is_straming']==0) echo 'selected="selected"';?>>无</option>
					<option value="1" <?php if($data['is_straming']==1) echo 'selected="selected"';?>>有</option>
				</select>
			</div>
		</div>
		<div class="col-sm-offset-2 col-sm-10">
			<button type="button" class="btn btn-primary" id="js-ajax-submit">{:lang("SAVE")}</button>
			<a class="btn btn-default" href="{:url('AdminOauth/dutyList')}">返回</a>
		</div>
	</form>

</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
	$('#js-ajax-submit').on('click', function () {
		var data = {
			id:"{$data['id']|default=''}",
			is_straming:$("#is_straming option:selected").val(),
			is_meeting:$("#is_meeting option:selected").val(),
			duty:$.trim($("input[name='duty']").val()),
		}

		if ( data.duty == '' || data.duty == null ) {
			tishi('职称不能为空')
			return false
		}

        $.ajax({
		        url: "{:url('AdminOauth/dutyForm')}",
		        dataType: 'json',
		        data: data,
		        type: "POST",
		        success: function(data){
					if (data.code == '1') {
		                noty({
		                    text: data.msg,
		                    type: 'success',
		                    layout: 'topCenter',
		                    modal: true,
		                    timeout: 800,
		                    callback: {
		                        afterClose: function () {
	                                if (data.url) {
	                                    //返回带跳转地址
	                                    window.location.href = data.url;
	                                } else {
	                                    //刷新当前页
	                                    reloadPage(window);
	                                }
		                        }
		                    }
		                }).show();
		            } else if (data.code == '0') {
		                art.dialog({
		                    content: data.msg,
		                    icon: 'warning',
		                    title: '提示',
		                    ok: function () {
		                        this.title(data.msg);
		                        return true;
		                    }
		                });
		            }
		        }
	        });
    });

    // 信息提示
    function tishi(msg){
    	art.dialog({
            id: 'warning',
            icon: 'warning',
            title: '提示',
            content: msg,
            cancelVal: '关闭',
            ok: function () {
              
            }
        });
    }
</script>
</body>
</html>